package com.dmap.analysispoint.service.impl;

import com.dmap.analysispoint.bo.DataBoardBo;
import com.dmap.analysispoint.constants.BurialPointConstant;
import com.dmap.analysispoint.service.CacheUtilsService;
import com.dmap.base.cache.impl.BaseCacheDaoStringImpl;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
@Service
public class CacheUtilsServiceImpl extends BaseCacheDaoStringImpl implements CacheUtilsService {

    /**
     * 添加缓存工具类
     */
    @Override
    public boolean addCache(DataBoardBo dataBoardBo, String cacheKey) {

        boolean success = false;
            String value = getKV(cacheKey);
            if (StringUtils.isBlank(value)) {
                addKV(cacheKey,dataBoardBo.toString(),BurialPointConstant.CACHE_TIME_ONE_DAY);
                success = true;
            }else {
                updateKV(cacheKey,dataBoardBo.toString(),BurialPointConstant.CACHE_TIME_ONE_DAY);
                success = true;
            }
        return success;
    }
}
